/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "pedido", catalog = "bd_subway", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pedido.findAll", query = "SELECT p FROM Pedido p"),
    @NamedQuery(name = "Pedido.findByPedId", query = "SELECT p FROM Pedido p WHERE p.pedId = :pedId"),
    @NamedQuery(name = "Pedido.findByPedFecha", query = "SELECT p FROM Pedido p WHERE p.pedFecha = :pedFecha")})
public class Pedido implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "pedId")
    private Integer pedId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "pedFecha", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date pedFecha;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "regPedPedidoId")
    private List<PedidoRegistro> pedidoRegistroList;
    @JoinColumn(name = "pedEstadoId", referencedColumnName = "estPId", nullable = false)
    @ManyToOne(optional = false)
    private PedidoEstado pedEstadoId;
    @JoinColumn(name = "pedMedPagoId", referencedColumnName = "medioId", nullable = false)
    @ManyToOne(optional = false)
    private MedioPago pedMedPagoId;
    @JoinColumn(name = "pedEmpId", referencedColumnName = "empId", nullable = false)
    @ManyToOne(optional = false)
    private Empleado pedEmpId;
    @JoinColumn(name = "pedUsuarioId", referencedColumnName = "usuarioId", nullable = false)
    @ManyToOne(optional = false)
    private UsuarioPersonaRol pedUsuarioId;

    public Pedido() {
    }

    public Pedido(Integer pedId) {
        this.pedId = pedId;
    }

    public Pedido(Integer pedId, Date pedFecha) {
        this.pedId = pedId;
        this.pedFecha = pedFecha;
    }

    public Integer getPedId() {
        return pedId;
    }

    public void setPedId(Integer pedId) {
        this.pedId = pedId;
    }

    public Date getPedFecha() {
        return pedFecha;
    }

    public void setPedFecha(Date pedFecha) {
        this.pedFecha = pedFecha;
    }

    @XmlTransient
    public List<PedidoRegistro> getPedidoRegistroList() {
        return pedidoRegistroList;
    }

    public void setPedidoRegistroList(List<PedidoRegistro> pedidoRegistroList) {
        this.pedidoRegistroList = pedidoRegistroList;
    }

    public PedidoEstado getPedEstadoId() {
        return pedEstadoId;
    }

    public void setPedEstadoId(PedidoEstado pedEstadoId) {
        this.pedEstadoId = pedEstadoId;
    }

    public MedioPago getPedMedPagoId() {
        return pedMedPagoId;
    }

    public void setPedMedPagoId(MedioPago pedMedPagoId) {
        this.pedMedPagoId = pedMedPagoId;
    }

    public Empleado getPedEmpId() {
        return pedEmpId;
    }

    public void setPedEmpId(Empleado pedEmpId) {
        this.pedEmpId = pedEmpId;
    }

    public UsuarioPersonaRol getPedUsuarioId() {
        return pedUsuarioId;
    }

    public void setPedUsuarioId(UsuarioPersonaRol pedUsuarioId) {
        this.pedUsuarioId = pedUsuarioId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pedId != null ? pedId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pedido)) {
            return false;
        }
        Pedido other = (Pedido) object;
        if ((this.pedId == null && other.pedId != null) || (this.pedId != null && !this.pedId.equals(other.pedId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Estado: " + this.pedEstadoId;
    }
    
}
